package com.cn.xly2023.controller;

import com.cn.xly2023.mapper.GoodsMapper;
import com.cn.xly2023.pojo.Goods;
import com.cn.xly2023.pojo.User;
import com.cn.xly2023.service.GoodsService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@Api(value = "商品数据test",tags = "商品数据接口API")
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;


    @RequestMapping(value = "/selectAll",method = RequestMethod.GET)
    public Map<String,Object> selectAll(){
        return goodsService.selectAll();
    }

    @RequestMapping(value = "/selectById",method = RequestMethod.GET)
    public Map<String,Object> selectById(@RequestParam Integer id){
        return goodsService.selectById(id);
    }

    @RequestMapping(value = "selectByPage",method = RequestMethod.GET)
    public Map<String,Object> selectByPage(@RequestParam Integer page,@RequestParam Integer limit,String goodsname,String price){
        return goodsService.selectByPage(page,limit,goodsname,price);

    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> insert(@RequestBody Goods goods){
        return goodsService.insert(goods);

    }

    @RequestMapping(value = "updateById",method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Goods goods) {
        return goodsService.updateById(goods);
    }


    @RequestMapping(value = "deleteById",method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestParam Integer id){
        return goodsService.deleteById(id);}

}
